<!--通过展示专家信息-->
<template>
  <span>
    {{ showValue }}
  </span>
</template>
<script setup>
import {getFacility as getModel} from "@/api/yz/facility"

import {watch, ref, onMounted} from "vue";

const props = defineProps({
  id: {
    type: Number,
    default: null
  },
  // 展示字段
  field: {
    type: String,
    default: 'name'
  }
})
// 展示字段
const showValue = ref('')
const loadModel = async () => {
  if (!props.id) {
    return;
  }
  const res = await getModel(props.id);
  showValue.value = res[props.field];
}
// 当参数变化时重新加载
onMounted(loadModel)
watch(props, loadModel)
</script>
